package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TContiStudyInfo;
import cn.com.headfree.mouldshow.dao.TContiStudyInfoDao;
import cn.com.headfree.vo.simple.ContiStudyInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tContiStudyInfoDao")
public class TContiStudyInfoDaoImpl extends BaseDaoImpl<TContiStudyInfo> implements TContiStudyInfoDao {


    @Override
    public List<ContiStudyInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_time,DATE_FORMAT(t.start_time,'%Y-%m-%d %H:%i:%s') as start_time_str,t.end_time,DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s') as end_time_str,t.major,t.study_place,GET_DIC('PeixunshoukeType',t.type) as type,t.certifier,u.xb_name as user_name from t_conti_study_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,t.major,t.study_place,GET_DIC('PeixunshoukeType',t.type) as type,t.certifier,u.`NAME` as user_name from t_conti_study_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_time,t.end_time,t.major,t.study_place,t.type,t.certifier,u.`NAME` as user_name from t_conti_study_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_time DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(ContiStudyInfoVo.class, sql.toString(), null, false, params);
    }
}
